<?php
$query = $_GET['search'];

$first='http://gdata.youtube.com/feeds/api/videos?q=';
$second=str_replace(' ', '%20', $query);
$third='&orderby=relevance&max-results=1&alt=json';
$key='&key=AI39si4YSDe1lkU6-yY1v-oEFe992820MM85Qt0QgVqJAo-4JPy0ABXGNFTyGrDYifFMzVI-ztCk1RY1aCXkPILKw2d6NkCWKQ';
$url=$first.$second.$third;

$html=file_get_contents($url);

$json=json_decode($html,true);
$link=$json['feed']['entry'][0]['link'][0]['href'];
$out='';
for($i=31;$i<42;$i++){
    $out.=$link[$i];
}
print($out);
?>
